﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGinnBPM.Lib.Interfaces;
using NGinnBPM.MessageBus;
using NGinnBPM.Lib.Schema;
using NGinnBPM.Lib.Data;

namespace NGinnBPM.Runtime
{
    internal class TaskContext : ITaskContext
    {
        private INGEnvironment _env;
        private ProcessDefinition _proc;
        private IMessageBus _bus;
        #region ITaskContext Members

        /// <summary>
        /// Task's document instance
        /// </summary>
        public IDynData Document { get; set; }

        public NGinnBPM.Lib.Interfaces.INGEnvironment Environment
        {
            get { return _env; }
            set { _env = value; }
        }

        public NGinnBPM.Lib.Schema.ProcessDefinition ParentProcess
        {
            get { return _proc; }
            set { _proc = value; }
        }

        public IMessageBus MessageBus
        {
            get { return _bus; }
            set { _bus = value; }
        }

        public IProcessPackageRepository PackageRepository
        {
            get { return ((NGEnvironment)Environment).PackageRepository; }
        }

        public NGinnBPM.Services.IProcessScriptManager ScriptManager
        {
            get { return ((NGEnvironment)Environment).ScriptManager; }
        }

        public NGinnBPM.Services.IMessageCorrelationIdResolver MessageCorrelationIdResolver
        {
            get { return ((NGEnvironment) Environment).MessageCorrelationIdResolver; }
        }

        #endregion

        #region ITaskContext Members


        public IServiceResolver ServiceLocator
        {
            get { return ((NGEnvironment)Environment).ServiceLocator; }
        }

        #endregion
    }
}
